package com.example.admin.controller;

import com.example.admin.Dto.Floordto;
import com.example.admin.Dto.Roomdto;
import com.example.admin.base.ResponseResult;
import com.example.admin.service.Floorservice;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/floor")
public class FloorWeb {
    @Autowired
    Floorservice floorservice;
    @GetMapping("/getAllFloorsWithDevice")
    public ResponseResult getAllFloorsWithDevice(){
      Floordto[] floors =   floorservice.getAllFloorsWithDevice();
      return ResponseResult.success(floors);
    }
@GetMapping("/getRoomsWithDeviceByFloorId/{floorId}")
    public ResponseResult getRoomsWithDeviceByFloorId(@PathVariable(value = "floorId") Long floorId){
       Roomdto[] roomdtos =  floorservice.getRoomsWithDeviceByFloorId(floorId);
       return ResponseResult.success(roomdtos);
    }
}
